<%@page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<html>
<head>

<script type="text/javascript">
var listUrl = "shop/shopList.do";
var p;
$(document).ready(function() {
	$("#shop-dg").datagrid({
			loadMsg : '数据加载中....',
			width : '100%',
			url : listUrl,
			nowrap : false,
			striped : true,
			sortOrder : 'desc',
			remoteSort : false,
            pageSize: 20,
			rownumbers : true,
			pagination : true,
			pageList : [ 10, 15, 20, 25 ],
			fitColumns : true,
			frozenColumns : [ [ {
				field : 'id',
				checkbox : true
			}, {
				title : '店铺id',
				field : 'id',
				width : 0,
				hidden : 'false'
			} ] ],
			columns : [ [
					{
						field : 'name',
						title : '店铺名称',
						width : 210
					},
					{
						field : 'position',
						title : '位置',
						width : 100
					},
					{
						field : 'orderMoneyHistory',
						title : '历史总订单金额',
						width : 100
					},
					{
						field : 'refundHistory',
						title : '历史总退款',
						width : 100
					},
					{
						field : 'partionHistory',
						title : '历史总抽成',
						width : 100
					},
					{
						field : 'couponTotalMoney',
						title : '历史优惠券总抵扣',
						width : 100
					},
					{
						field : 'totalMoney',
						title : '最终总收入',
						width : 100
					},
					{
						field : 'poundageTotalMoney',
						title : '历史总手续费',
						width : 100
					},
					{
						field : 'platformProfitTotal',
						title : '平台总盈亏',
						width : 100
					},
					{
						field : 'refundCount',
						title : '被退款次数',
						width : 100
					},
					{
						field : 'businessStatus',
						title : '状态',
						width : 100,
						formatter : function(val){
							return businessStatus(val);
						}
					},
					{
						field : 'certifiedStatus',
						title : '认证状况',
						width : 100,
						formatter : function(val){
							return certifiedStatus(val);
						}
					}
			] ]
		});// end datagrid
	//设置分页控件
	p = $('#shop-dg').datagrid('getPager');
	$(p).pagination(
				{
					pageSize : 20,//每页显示的记录条数，默认为10
					pageList : [ 20, 25 ],//可以设置每页记录条数的列表
					beforePageText : '第',//页数文本框前显示的汉字
					afterPageText : '页    共 {pages} 页',
					displayMsg : '当前显示 {from} - {to} 条记录   共 {total} 条记录',
					onBeforeRefresh : function() {
						$(this).pagination('loading');
						$(this).pagination('loaded');
					}
				});//end pagination

	}); //end ready

	function info() {
        var rows = $('#shop-dg').datagrid('getSelections');
        if (rows.length != 1) {
            $.messager.alert('操作提示', "请先选择一条要查看的信息！");
            return;
        }
        var row = $('#shop-dg').datagrid('getSelected');
        var id=row.id;

        var url = "shop/details.do?id=" + id;
        $.get(url, row,
            function(data) {
                $("#center").empty();
                $("#center").html(data);
                $.parser.parse($("#center"));
            });
      }

function productList() {
    var rows = $('#shop-dg').datagrid('getSelections');
    if (rows.length != 1) {
        $.messager.alert('操作提示', "请先选择一条要查看的信息！");
        return;
    }
    var row = $('#shop-dg').datagrid('getSelected');
    var id=row.id;

    var url = "shop/productList.do?id=" + id;
    $.get(url, row,
        function(data) {
            $("#center").empty();
            $("#center").html(data);
            $.parser.parse($("#center"));
        });
}

function dailyFlow() {
    var rows = $('#shop-dg').datagrid('getSelections');
    if (rows.length != 1) {
        $.messager.alert('操作提示', "请先选择一条要查看的信息！");
        return;
    }
    var row = $('#shop-dg').datagrid('getSelected');
    var id=row.id;

    var url = "order/dailyFlow.do?id=" + id;
    $.get(url, row,
        function(data) {
            $("#center").empty();
            $("#center").html(data);
            $.parser.parse($("#center"));
        });
}

function exportHis(){
	var pageIndex = $(".pagination-num").val();
	var pageSize = $(".pagination-page-list  option:selected").text();
    var url = "shop/exportShopList.do?pageIndex=" + pageIndex + "&pageSize="+pageSize;
    window.open(url);
}

</script>
</head>
<body>
	<div class="linkbar"><a>店铺管理</a>/<a>店铺信息</a></div>
	<div class="clear"></div>
	<div id="shop-dg" toolbar="#toolbar"></div>
    <div id="toolbar">
	    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="info()">店铺详情</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="dailyFlow()">每日流水</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="productList()">商品列表</a>
		<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="exportHis()">导出</a>
    </div>
</body>
</html>